//
//  HKUIUtils.h
//  HKOnLine
//


#import <UIKit/UIKit.h>

extern NSString *setupMD5StringForKey(NSString *key);
extern UIColor *colorWithHexAndAlpha(long hexColor, float opacity);
extern UIColor *colorWithHex(long hexColor);
extern NSString *removeDecWith(NSString *str);
extern NSString *downCountToWanString(NSInteger count);
extern NSString *pariseCountString(NSInteger count);
extern NSString *detailPariseCountString(NSInteger count);
extern NSString *detailViewCountString(NSString *countStr);
extern NSString *detailReplyCountString(NSString *countStr);
extern NSString *messageRedCountString(NSString *countStr);
extern NSString *circleHotCountString(NSString *countStr);
extern NSString *stringFormatFileSize(long long size);
extern NSString *stringFormatFileSizeSmartUnit(long long size, long long totalSize);
extern CGFloat floatValueFromHumanityString(NSString *sizeString, NSInteger trailUnitLength);
extern CGFloat getSystemSize(void);
extern CGFloat getSystemFreeSize(void);
@interface HKUIUtils : NSObject

#pragma mark - FitFontSize

/**
 *  适配字体大小，6下字体大一，6P下字体大2
 *
 *  @param size 字体大小
 *
 *  @return 适配后的字体
 */
+ (UIFont *) fitSystemUIFontWithSize:(CGFloat)size;
+ (UIFont *) fitBoldSystemUIFontWithSize:(CGFloat)size;

+ (void)scrollTableViewToBottom:(UITableView *)tableView
                  withAnimation:(BOOL)animation;

+ (__kindof UIView *) addLineInView:(UIView *)parentView
                                top:(BOOL)isTop
                         leftMargin:(CGFloat)leftMargin
                        rightMargin:(CGFloat)rightMargin;





/**
 画虚线

 @param parentView parentView description
 @param color color description
 @param isTop isTop description
 @param leftMargin leftMargin description
 @param rightMargin rightMargin description
 @return return value description
 */
+ (__kindof CAShapeLayer *) addDottedLineView:(UIView *)parentView color:(UIColor *)color top:(BOOL)isTop leftMargin:(CGFloat)leftMargin rightMargin:(CGFloat)rightMargin;

+ (__kindof UIView *) addLineInView:(UIView *)parentView color:(UIColor *)color top:(BOOL)isTop leftMargin:(CGFloat)leftMargin rightMargin:(CGFloat)rightMargin;

+ (__kindof UIView *) addEmptyViewInView:(UIView *)parentView color:(UIColor *)color top:(BOOL)isTop leftMargin:(CGFloat)leftMargin rightMargin:(CGFloat)rightMargin emptyheight:(CGFloat )emptyHeight;

//画竖线
+ (__kindof UIView *)addVerticalLineInView:(UIView *)parentView
                                     right:(BOOL)isRight
                                 topMargin:(CGFloat)topMargin
                              bottomMargin:(CGFloat)bottomMargin;


+ (__kindof UIView *) addVerticalLineInView:(UIView *)parentView
                                      right:(BOOL)isRight
                                      color:(UIColor *)color
                                  topMargin:(CGFloat)topMargin
                               bottomMargin:(CGFloat)bottomMargin;

//画虚线
+ (void)drawLineOfDashByCAShapeLayer:(UIView *)lineView lineLength:(int)lineLength lineSpacing:(int)lineSpacing lineColor:(UIColor *)lineColor lineDirection:(BOOL)isHorizonal;

+ (UIImage *)imageWithLineWithImageView:(UIImageView *)imageView;

/**
 *  获得某个范围内的屏幕图像
 *
 *  @param theView View
 *  @param frame   frame
 *
 *  @return Image
 */
+ (UIImage *)getImageFromView:(UIView *)theView atFrame:(CGRect)frame;

/**
 *  UIView提取Image
 *
 *  @param theView View
 *
 *  @return Image
 */
+ (UIImage *)getImageFromView:(UIView *)theView;

/**
 *  获取切图
 *
 *  @param currentScrollView currentView description
 *
 *  @return return value description
 */
+ (UIImage *)getScreenImageFromView:(UIScrollView *)currentScrollView;

/**
 *  获取圆角蒙版Image 永久保存内存
 *
 *  @param isCutOuter   YES:裁剪外部 NO:裁剪内部
 *  @param size         大小
 *  @param radius       圆角
 *  @param color        蒙版颜色
 *  @param strokeColor  内框颜色
 *
 *  @return Image
 */
+ (UIImage *)getRoundImageWithCutOuter:(BOOL)isCutOuter
                                  Size:(CGSize)size
                                Radius:(CGFloat)radius
                                 color:(UIColor *)color
                       withStrokeColor:(UIColor *)strokeColor;



/**
 获取圆角试图加边框

 @param soureView soureView description
 @param radiu radiu description
 @param color color description
 @return return value description
 */
+ (UIView *)getRoundViewAndLayerBoredWith:(UIView *)soureView
                                    radiu:(CGFloat )radiu
                                boreColor:(UIColor *)color;

/**
 *  获取纯色圆角Image
 *
 *  @param corners         圆角位置
 *  @param radius          圆角半径
 *  @param frame           frame
 *  @param backgroundcolor 背景颜色
 *  @param strokeColor     描边颜色
 *  @param lineWidth       描边线段宽度
 */
+ (UIImage *)getImageWithRoundingCorners:(UIRectCorner)corners
                            cornerRadius:(CGFloat)radius
                                   frame:(CGRect)frame
                         backgroundcolor:(UIColor *)backgroundcolor
                             strokeColor:(UIColor *)strokeColor
                               lineWidth:(CGFloat)lineWidth;

/**
 *  生成用于拉伸的UIImage图 (2x1 Or 1*2)像素永久保存内存
 *
 *  @param isVertical      是否垂直拉伸
 *  @param isFirstOpaque   是否第一像素不透明
 *  @param highlightColor  显示的颜色
 *
 *  @return image
 */
+ (UIImage *)getLineImageWithIsVertical:(BOOL)isVertical
                     isFirstPixelOpaque:(BOOL)isFirstOpaque
                         highlightColor:(UIColor *)highlightColor;

+ (UIImage*) clipRoundImageWithImage:(UIImage*)origImage
                               frame:(CGRect)frame
                              Radius:(CGFloat)r
                         StrokeColor:(UIColor *)strokeColor;

/**
 *  @brief  裁剪出无锯齿圆角 Cover
 *  @param isCutOuter   YES:裁剪外部 NO:裁剪内部
 *  @param origImage         原始图片
 *  @param r            半径
 *  @param strokeColor  内框颜色
 *
 *  @return 裁剪后得到的无锯齿圆角 Cover
 */
+ (UIImage*) clipRoundImageWithImage:(UIImage*)origImage
                            CutOuter:(BOOL)isCutOuter
                              Radius:(CGFloat)r
                         StrokeColor:(UIColor *)strokeColor;


+ (UIImage*) clipRoundImageWithImage:(UIImage*)origImage
                            CutOuter:(BOOL)isCutOuter
                              Radius:(CGFloat)r
                         StrokeColor:(UIColor *)strokeColor
                     StrokeLineWidth:(CGFloat)lineWidth;



/**
 *  给图片添加水印
 *
 *  @param image 背景图
 *  @param text  需要添加的水印
 *  @param attr  文字的属性
 *  @param rect 位置
 *
 */
+ (UIImage *)getImageWithImage:(UIImage *)image
                          text:(NSString *)text
                     attribute:(NSDictionary *)attr
                        InRect:(CGRect)rect;

/**
 *  @brief  生成 masklayer
 *
 *  @param corners 那几个圆角
 *  @param view    要设置的View
 *  @param radius  圆角半径
 *
 */
+ (CAShapeLayer *)makeShapelayerWithRoundingCorners:(UIRectCorner)corners
                                            forView:(UIView*)view
                                   withCornerRadius:(CGFloat)radius;


/**
 *  @brief  设置 View 圆角
 *
 *  @param view   要设置的View
 *  @param radius 圆角半径
 */
+ (void)setRoundingCorners:(UIView *)view withCornerRadius:(CGFloat)radius;


/**
 *  @brief  设置 View 两上角为圆角
 *
 *  @param view   要设置的View
 *  @param radius 圆角半径
 */
+ (void)setTopRoundingCorners:(UIView *)view withCornerRadius:(CGFloat)radius;

/**
 *  @brief  设置 View 两下角为圆角
 *
 *  @param view   要设置的View
 *  @param radius 圆角半径
 */
+ (void)setBottomRoundingCorners:(UIView *)view withCornerRadius:(CGFloat)radius;

/**
 *  @brief  设置 View 左边两角为圆角
 *
 *  @param view   要设置的View
 *  @param radius 圆角半径
 */
+ (void)setLeftRoundingCorners:(UIView *)view withCornerRadius:(CGFloat)radius;

/**
 *  @brief  设置 View 右边边两角为圆角
 *
 *  @param view   要设置的View
 *  @param radius 圆角半径
 */
+ (void)setRightRoundingCorners:(UIView *)view withCornerRadius:(CGFloat)radius;



/**
 *  @brief  裁剪出对应设置的圆角图片，有路径线条显示时，可使圆角显示正常
 *
 *  @param corners     所设置的圆角
 *  @param view        要裁剪的 view
 *  @param radius      半径
 *  @param color       颜色
 *  @param strokeColor 描边颜色
 *  @param lineWidth   描边宽度
 *
 */
+ (UIImage *)clipImageWithRoundingCorners:(UIRectCorner)corners
                                  ForView:(UIView*)view
                             CornerRadius:(CGFloat)radius
                                    Color:(UIColor *)color
                              StrokeColor:(UIColor *)strokeColor
                                LineWidth:(CGFloat)lineWidth;

/**
 *  等比放缩图片尺寸
 *
 *  @param img  要放缩的图片
 *  @param size 要放缩的尺寸
 *
 *  @return 返回对应放缩的图片
 */
+ (UIImage *)scaleImageToSize:(UIImage *)img size:(CGSize)size;

/**
 *  等比放缩图片尺寸
 *
 *  @param image       要放缩的图片
 *  @param scaleRate 要放缩的比例
 *
 *  @return 返回对应放缩的图片
 */
+ (UIImage *)scaleImageToSize:(UIImage *)image scaleRate:(CGFloat)scaleRate;

/**
 *  设置按钮为图片在上方，标题在下方样式,注意需要先设置好Button的frame
 *
 *  @param button 要设置的UIButton
 *  @param margin 图片和标题的间距
 */
+ (void)setImageUpAndTitleDownStyleFor:(UIButton *)button withImageAndTitleMargin:(CGFloat)margin;




@end
